package com.hadoop.mr.reduceJoin;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @program: hadoop
 * @description: 表对应实体
 * @author: Qiang.Ye
 * @date: 2019-06-09 11:55
 **/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class TableBean implements Writable {

    /**
     * 订单ID
     */
    private     String          orderId;
    /**
     * 产品ID
     */
    private     String          pid;
    /**
     * 数量
     */
    private     int          amount;
    /**
     * 产品名称
     */
    private     String          pname;
    /**
     * 标记
     */
    private     String          flag;





    @Override
    public void write(DataOutput output) throws IOException {
        output.writeUTF(orderId);
        output.writeUTF(pid);
        output.writeInt(amount);
        output.writeUTF(pname);
        output.writeUTF(flag);
    }

    @Override
    public void readFields(DataInput input) throws IOException {
        this.orderId = input.readUTF();
        this.pid = input.readUTF();
        this.amount = input.readInt();
        this.pname = input.readUTF();
        this.flag = input.readUTF();
    }


    @Override
    public String toString() {
        return orderId + '\'' + amount + '\'' + pname + '\'';
    }
}
